//
//  FMPersonCell.m
//  NewMyMusicAPP
//
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "FMPersonCell.h"

@implementation FMPersonCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
    
}


-(void)createSubview
{

    
    self.coverOrigin = [[UIImageView alloc]initWithFrame:CGRectMake(20 * WIDTH, 15 * HEIGHT, 80 * WIDTH, 80 * WIDTH)];
    self.coverOrigin.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.coverOrigin];
    [_coverOrigin release];
    self.coverOrigin.layer.masksToBounds = YES;//设置圆角边缘
    self.coverOrigin.layer.cornerRadius = self.coverOrigin.frame.size.height / 2;//设置弧度
    
    
    //标题
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(120 * WIDTH, 0, 250 * WIDTH, 60 * HEIGHT)];
    self.title.numberOfLines = 0;
    self.title.text = @"标题";
    self.title.font = [UIFont systemFontOfSize:18];
    self.title.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.title];
    [_title release];
    

    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(120 * WIDTH, 60 *HEIGHT, 40 * WIDTH, 30 * HEIGHT)];
    label.text = @"by ";
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:label];
    [label release];
    
    
    self.albumTitle = [[UILabel alloc]initWithFrame:CGRectMake(145 * WIDTH, 60 * HEIGHT, 150 * WIDTH, 30 *HEIGHT)];
    [self.contentView addSubview:self.albumTitle];
    [_albumTitle release];
    self.albumTitle.text = @"作者";
    self.albumTitle.textColor = [UIColor orangeColor];
    self.albumTitle.font = [UIFont systemFontOfSize:15];
    
    
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(120 *WIDTH, 80 * HEIGHT, 15 * WIDTH, 15 *HEIGHT)];
    [self.contentView addSubview:image];
    [image release];
    image.image = [UIImage imageNamed:@"player.png"];
    
    
    _playtimes = [[UILabel alloc]initWithFrame:CGRectMake(300* WIDTH, 60 *HEIGHT, 70 * WIDTH, 15 * HEIGHT)];
    _playtimes.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_playtimes];
    [_playtimes release];
    _playtimes.textColor = [UIColor yellowColor];
    _playtimes.text = @"1000";
    
    
    UIImageView *like = [[UIImageView alloc]initWithFrame:CGRectMake(180 * WIDTH,  80 * HEIGHT, 15 *WIDTH, 15 *HEIGHT)];
    [self.contentView addSubview:like];
    [like release];
    like.image = [UIImage imageNamed:@"like.png"];
    
    
//    _likes = [[UILabel alloc]initWithFrame:CGRectMake(198 * WIDTH, 80 * HEIGHT, 80 * WIDTH, 15 *HEIGHT)];
//    _likes.font = [UIFont systemFontOfSize:15];
//    [self.contentView addSubview:_likes];
//    [_likes release];
//    _likes.text = @"456";
//    _likes.textColor = [UIColor colorWithHexString:@"FFCCCC"];
//    
    
    
}


-(void)setModel:(FMPersonModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    _title.text = _model.title;

    _albumTitle.text = _model.albumTitle;
    NSURL *url = [NSURL URLWithString:_model.coverLarge];

    [_coverOrigin sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"cell_bg_noData_1@2x.png"]];
    
    float number = [_model.playtimes floatValue];
    NSString *count = @"";
    if (number > 10000) {
        number = number / 10000;
        count = [NSString stringWithFormat:@"%.1f万",number];
        _playtimes.text = count;
        return;
    }
    
    _playtimes.text = [NSString stringWithFormat:@"%@",_model.playtimes];
    
}




- (void)awakeFromNib {

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
